var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var UI_GameEquipInfo_UIBindings = require("AA_UI_GameEquipInfo_UIBindings");
var UIView = require("AA_UIView");
var Excel = require("AA_Excel");
var HallGlobalVariable = require("AA_HallGlobalVariable");
var BundleConfig = require("AA_BundleConfig");
var ExcelUtil = require("AA_ExcelUtil");
var CommonUtils = require("AA_CommonUtils");
var BuffMag = require("AA_BuffMag");
var Const_Game = require("AA_Const_Game");
var GameGlobalVariable = require("AA_GameGlobalVariable");
var Logic_GetEquip = require("AA_Logic_GetEquip");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_GameEquipInfo = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.auto_ui = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.onLoad = function () {
    this.auto_ui.node_light.runAction(cc.repeatForever(cc.rotateBy(5, 360)));
  };
  _creator.prototype._show = function (e) {
    var t = this;
    this.shuiGuoId = e.shuiGuoId;
    this.level = e.level;
    this.GetAttribute();
    var o = Logic_GetEquip.default.I.GetMaxLevel(e.shuiGuoId) == GameGlobalVariable.GameGlobalVariable.zaZhongMaxLevel;
    this.auto_ui.node_zaZhongTip.active = o;
    if (o) {
      var n = Excel.Excel.shuiguo(e.shuiGuoId);
      var i = Excel.Excel.shuiguo(Logic_GetEquip.default.I.GetZaZhongId(this.shuiGuoId));
      this.auto_ui.txt_zaJiaoTipLabel.string = "4阶" + n.name + "可与4阶" + i.name + "杂交合成至5阶";
      var a = "player" + ((0 != n.jinjieShuiGuoId ? n : i).id - 1e3) + "_5";
      this.auto_ui.node_zaZhongName.children.forEach(function (e) {
        e.active = e.name == a;
      });
    }
    this.auto_ui.node_tianFuNode.active = false;
    if (4 == e.level) {
      this.auto_ui.node_zaZhongTip.active = false;
      CommonUtils.default.LoadLevel5Effect(this.shuiGuoId, this.auto_ui.node_qiFather, this.auto_ui.node_huoFather, this._loadRes.bind(this));
      this.auto_ui.node_tianFuNode.active = true;
      this._loadRes(BundleConfig.BundleNames.Common, "common/" + "res/tianfuicon/tianfu_" + e.shuiGuoId + "_1", cc.SpriteFrame).then(function (e) {
        t.auto_ui.sp_ciTiaoIcon.spriteFrame = e;
      });
      var r = -1;
      Excel.Excel.shuiguohecheng_all.forEach(function (t) {
        t.shuiguoId == e.shuiGuoId && 0 != t.newTianFuBuff && (r = t.newTianFuBuff);
      });
      if (-1 != r) {
        var c = Excel.Excel.shuiguo(e.shuiGuoId);
        var s = Excel.Excel.shuiguobuff(r);
        if (s) {
          var l = s.value;
          var p = s.buffdesc;
          var f = [p = CommonUtils.default.replaceSymbols(p, "\\n", [""])];
          -1 != p.indexOf("X") && (f = p.split("X"));
          var g = "";
          for (var y = 0; y < f.length; y++) {
            var v = f[y];
            if (-1 != v.indexOf("#")) {
              var b = '<color=#ffff00 click="ShowZaZhongInfo">' + c.newName + "</c>";
              b = "<u>" + b + "</u>";
              v = CommonUtils.default.replaceSymbols(v, "#", [b]);
            }
            g += "<color=#ffffff>" + v + "</c>";
            y < f.length - 1 && l && (g += "<color=#71ff00>" + l[y] + "</c>");
          }
          g = "<outline color=#000000 width=3>" + (g = "<b>" + g + "</b>") + "</outline>";
          this.auto_ui.rtxt_ciTiaoInfo.string = g;
        }
      }
    }
  };
  _creator.prototype._clickListener = function (e) {
    switch (e) {
      case this.auto_ui.btn_closeBtn:
        this._close();
    }
  };
  _creator.prototype.GetAttribute = function () {
    var e = this;
    var t = Excel.Excel.shuiguo(this.shuiGuoId);
    this._loadRes(BundleConfig.BundleNames.Common, "common/" + "res/player/player" + (this.shuiGuoId - 1e3) + "_" + (this.level + 1), cc.SpriteFrame).then(function (t) {
      e.auto_ui.sp_iconSprite.spriteFrame = t;
    });
    this.auto_ui.sp_tianFuIcon.spriteFrame = null;
    this.shuiGuoId != Const_Game.FruitId.杨桃忍者 && this._loadRes(BundleConfig.BundleNames.Common, "common/" + "res/tianfuicon/tianfu_" + this.shuiGuoId, cc.SpriteFrame).then(function (t) {
      e.auto_ui.sp_tianFuIcon.spriteFrame = t;
      CommonUtils.default.LimitSpriteMaxSize(e.auto_ui.sp_tianFuIcon, 80);
    });
    var o = HallGlobalVariable.default.GetShuiGuoCurrLevelData(this.shuiGuoId);
    if (this.level == GameGlobalVariable.GameGlobalVariable.normalMaxLevel) {
      this.auto_ui.txt_titleLabel.string = t.newName + "(LV." + (this.level + 1) + ")";
    } else {
      this.auto_ui.txt_titleLabel.string = t.name + "(LV." + (this.level + 1) + ")";
    }
    this.auto_ui.txt_tianFuLabel.string = t.shuiguomiaoshu;
    var n = ["最前", "随机", "轮流", "精英", "-", "随机", "最前", "-", "-", "最前"];
    var i = this.GetEquipAtk(t, this.level, o[0]);
    this.GetEquipAtk(t, this.level + 1, o[0]);
    this.auto_ui.node_attributeFather.children.forEach(function (o, a) {
      var r = o.getChildByName("value").getChildByName("valueLabel").getComponent(cc.Label);
      o.getChildByName("value").getChildByName("addLabel").getComponent(cc.Label).string = "";
      r.string = "-";
      switch (a) {
        case 0:
          if (0 != t.attack && e.shuiGuoId != Const_Game.FruitId.辣妹子) {
            if (Math.floor(i.sgattack) < i.sgattack || i.sgattack < 1 && i.sgattack > 0) {
              r.string = i.sgattack.toFixed(2);
            } else {
              r.string = "" + i.sgattack;
            }
          }
          break;
        case 1:
          if (0 != t.attackspeed) {
            if (Math.floor(i.sgattackspeed) < i.sgattackspeed || i.sgattackspeed < 1 && i.sgattackspeed > 0) {
              r.string = i.sgattackspeed.toFixed(2);
            } else {
              r.string = "" + i.sgattackspeed;
            }
          }
          break;
        case 2:
          r.string = n[t.attackstate - 1];
          break;
        case 3:
          var c = false;
          t.littleDesc && t.littleDesc.length > 0 && (c = true);
          o.getChildByName("nameLabel").getComponent(cc.Label).string = c ? t.littleDesc : "-";
          if (c) {
            var s = BuffMag.BuffMgr.getShuiGuoBuff(t.id, e.level);
            var l = "";
            switch (e.shuiGuoId) {
              case Const_Game.FruitId.爆头瓜:
              case Const_Game.FruitId.榴莲王:
              case Const_Game.FruitId.香蕉射手:
              case Const_Game.FruitId.黄瓜大棒:
              case Const_Game.FruitId.辣妹子:
              case Const_Game.FruitId.冻斯梨:
              case Const_Game.FruitId.毒蘑菇:
              case Const_Game.FruitId.天山雪莲:
              case Const_Game.FruitId.元婴果:
              case Const_Game.FruitId.至尊棒:
              case Const_Game.FruitId.紫薯精:
                l = "%";
            }
            r.string = Excel.Excel.shuiguobuff(t.talent).probability + l;
            if (e.shuiGuoId == Const_Game.FruitId.榴莲王 || e.shuiGuoId == Const_Game.FruitId.紫薯精) {
              r.string = Excel.Excel.shuiguobuff(t.talent).probability + l;
            } else if (e.shuiGuoId == Const_Game.FruitId.香蕉射手) {
              r.string = "" + s.otherValue + l;
            } else {
              r.string = "" + s.nowvalue + l;
            }
          }
      }
    });
  };
  _creator.prototype.GetEquipAtk = function (e, t, o) {
    var n = o.atk;
    var i = o.atkSpeed;
    var a = ExcelUtil.ExcelUtil.getSameData(Excel.Excel.shuiguohecheng_all, "shuiguoId", e.id);
    t >= a.length && (t = a.length - 1);
    var r = a[t];
    return {
      sgattack: n += n * r.addattack / 100,
      sgattackspeed: i /= 1 + r.addattackspeed / 100
    };
  };
  __decorate([_property(UI_GameEquipInfo_UIBindings.default)], _creator.prototype, "auto_ui", undefined);
  return __decorate([_ccclass], _creator);
}(UIView.default);
exports.default = _def_UI_GameEquipInfo;